﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using ClassLibrary.DAO;
using ClassLibrary.Data;
using ClassLibrary.Entity;

public partial class Client_UserControl_ucProcducts : System.Web.UI.UserControl
{
    TblItemsDAO ItemsDAO = new TblItemsDAO(Global.CONNECTION_STRING);
    protected void Page_Load(object sender, EventArgs e)
    {

        
    }

    public void LoadData(string strName, string strCatID, string strOrderby)
    {
        try
        {
            lvItems.DataSource = ItemsDAO.GetListItems(0,strName, strCatID, 1, 10, "");
            lvItems.DataBind();
        }
        catch (Exception ex)
        {
            Session[Global.SESSION_ERROR] = ex;
            Response.Redirect(Global.ERROR_PAGE, true);
        }
    }
    protected void btnSortedAsc_Click(object sender, ImageClickEventArgs e)
    {
          try
            {
               // int maxrow1 = itemDAO.GetItemCount("", "", cboSortBy.SelectedValue);
                lvItems.DataSource = ItemsDAO.GetListItems(0, "", "", 1, 10, cboSortBy.SelectedValue+ " " + "ASC");
                lvItems.DataBind();
            }
            catch (Exception ex)
            {
                Session[Global.SESSION_ERROR] = ex;
                Response.Redirect(Global.ERROR_PAGE);
            }  
    }
    protected void btnSortDesc_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            // int maxrow1 = itemDAO.GetItemCount("", "", cboSortBy.SelectedValue);
            lvItems.DataSource = ItemsDAO.GetListItems(0, "", "", 1, 10, cboSortBy.SelectedValue + " " + "DESC");
            lvItems.DataBind();
        }
        catch (Exception ex)
        {
            Session[Global.SESSION_ERROR] = ex;
            Response.Redirect(Global.ERROR_PAGE);
        }  
    }
   
    protected void lvItems_PagePropertiesChanged(object sender, EventArgs e)
    {
       lvItems.DataBind();
    }

 
}
